<?php

require_once 'Zend/Auth/Adapter/DbTable.php';


class Myzen_Auth_Adapter_DbTable extends Zend_Auth_Adapter_DbTable {

  /* defintion of the consumer table */
  protected $_dbUserCredentialTableName = 'userCredential';
  static protected $_dbUserCredentialEmailCol = 'email';
  static protected $_dbUserCredentialPasswordCol = 'password';

  public function __construct($email,$password) {  
  	
  	
    $validator = new Zend_Validate_EmailAddress();
    if (!$validator->isValid($email)) {
      throw new Zend_Auth_Exception('email is invalid');
    }
  	
  	
  	
  	$db = Zend_Registry::get('dt_dbs')->getDb('user','details','key');


    
    parent::__construct($db,
    $this->_dbUserCredentialTableName,
    self::$_dbUserCredentialEmailCol,
    self::$_dbUserCredentialPasswordCol);
   
    $this->setIdentity($email);
    $this->setCredential(sha1($password));
    
    return;
  }


}